import {activityStrategyArmory} from "@/apis";

export function StrategyArmory() {
    const strategyArmoryHandle = async ()=>{
        // url 上获取参数
        const searchParams = new URLSearchParams(window.location.search);
        // 获取 strategyId 转换为 number类型
        const activityId = Number(searchParams.get('activityId'));
        if (!activityId){
            window.alert("请在请求地址中，配置 strategyId 值，如：http://localhost:3000/?userId=songwenshuai&activityId=100301&awardLockCheckFlag=day")
            return;
        }
        const result = await activityStrategyArmory(activityId);
        const {code, info} = await result.json();
        if(code != "0000"){
            window.alert("装配失败 code:" + code + " info:" + info)
            return
        }
    }
    return (
        <div
            className="px-6 py-2 mb-8 text-white bg-yellow-600 rounded-full shadow-lg hover:bg-yellow-800 focus:outline-none focus:ring-2 focus:ring-blue-300"
            style={{cursor: "pointer"}}
            onClick={strategyArmoryHandle}
        >
            装配抽奖「测试前点击预热数据」
        </div>
    );
}

